//
//  PaymentRecordCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2018/1/3.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "PaymentRecordCell.h"
#import "ImageBrowser.h"
@interface PaymentRecordCell ()
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;
@property (weak, nonatomic) IBOutlet UILabel *leftTopLabel;
@property (weak, nonatomic) IBOutlet UILabel *leftBottomLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;
@property (weak, nonatomic) IBOutlet UIButton *lookBtn;
@property (weak, nonatomic) IBOutlet ImageBrowser *myCollcetionVeiw;
@property (nonatomic, strong) NSMutableArray<NSURL *> *urls;

@end

@implementation PaymentRecordCell


- (NSMutableArray<NSURL *> *)urls{
    if (!_urls) {
        _urls = [NSMutableArray array];
    }
    
    
    return _urls;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.leftTopLabel.font = MYFONT(16);
    
    self.leftBottomLabel.font = MYFONT(14);
    
    self.leftBottomLabel.textColor = darkGray;
    
    self.rightLabel.font = MYFONT(17);
    
    self.bottomMargin.constant = 0;
    
    self.lookBtn.titleLabel.font = MYFONT(10);
    
    [self.lookBtn setTitleColor:themeColor forState:UIControlStateNormal];
    [self.lookBtn setTitleColor:themeColor forState:UIControlStateHighlighted];
    
    
    
    
    self.lookBtn.layer.borderColor = themeColor.CGColor;
    self.lookBtn.layer.borderWidth = 0.6;
    
    self.lookBtn.layer.cornerRadius = 13;
    self.lookBtn.layer.masksToBounds = YES;
    


    // Initialization code
    
//    [self.leftImageView sd_setImageWithURL:[NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1511331357944&di=b39df823edd6e2f8b1cf98a08e39bc05&imgtype=0&src=http%3A%2F%2Fpic1.16pic.com%2F00%2F15%2F60%2F16pic_1560933_b.jpg"] placeholderImage:nil];
}


- (void)setModel:(PaymentSDWModel *)model{
    _model = model;
    
    self.myCollcetionVeiw.index = self.index;

    
    [self.urls removeAllObjects];

    
    if ([self.type isEqualToString:@"1"]) {
        
        
        self.leftImageView.image = [UIImage imageNamed:@"dianfei22"];
        
        self.leftTopLabel.text = _model.bill_num;
        
        
    } else if ([self.type isEqualToString:@"2"]){
        
        self.leftImageView.image = [UIImage imageNamed:@"wangfei22"];
        
        self.leftTopLabel.text = _model.bill_num;
        
    }else{
        
        self.leftImageView.image = [UIImage imageNamed:@"shoujifei22"];
        
        self.leftTopLabel.text = _model.receiver_mobile;

    }
    
    
    self.leftBottomLabel.text = _model.create_time;
    
    self.rightLabel.text = _model.price;
    
    
    
    
//    if (_model.return_img.length > 0) {
//
//        self.myCollcetionVeiw.hidden = NO;
//
//        [self.lookBtn setTitle:@"查看回执" forState:UIControlStateNormal];
//        [self.lookBtn setTitle:@"查看回执" forState:UIControlStateHighlighted];
//
//        self.lookBtn.backgroundColor = [UIColor whiteColor];
//        self.lookBtn.layer.borderColor = themeColor.CGColor;
//        [self.lookBtn setTitleColor:themeColor forState:UIControlStateNormal];
//        [self.lookBtn setTitleColor:themeColor forState:UIControlStateHighlighted];
//        [self.urls addObject:[NSURL URLWithString:_model.return_img]];
//
//        self.myCollcetionVeiw.thumPicURLs = self.urls;
//
//        BrowserLayout *layout = (BrowserLayout *)self.myCollcetionVeiw.collectionViewLayout;
//
//        layout.itemSize = [layout itemSizeWitUrls:self.urls withMargin:KScreenW - 0.2];
//
//        [self.myCollcetionVeiw reloadData];
//
//
//
//    }else{
    
        self.myCollcetionVeiw.hidden = YES;
        [self.lookBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.lookBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        if ([_model.pay_status isEqualToString:@"0"]) {
            [self.lookBtn setTitle:@"去支付" forState:UIControlStateNormal];
            [self.lookBtn setTitle:@"去支付" forState:UIControlStateHighlighted];
            self.lookBtn.backgroundColor = [UIColor colorWithHexString:@"#F15050"];
            self.lookBtn.layer.borderColor = [UIColor colorWithHexString:@"#F15050"].CGColor;

        } else {
            
            [self.lookBtn setTitle:@"已付款" forState:UIControlStateNormal];
            [self.lookBtn setTitle:@"已付款" forState:UIControlStateHighlighted];
            self.lookBtn.backgroundColor = [UIColor colorWithHexString:@"#999999"];
            self.lookBtn.layer.borderColor = [UIColor colorWithHexString:@"#999999"].CGColor;


        }

        
//        self.lookBtn.hidden = YES;
//        [self.lookBtn setTitleColor:darkGray forState:UIControlStateNormal];
//        [self.lookBtn setTitleColor:darkGray forState:UIControlStateHighlighted];
//        self.lookBtn.layer.borderColor = darkGray.CGColor;
        
//    }
    


    
    
}

- (IBAction)lookBtnDidTap:(UIButton *)sender {
    
    if (_model.return_img.length > 0) {
    
    [[NSNotificationCenter defaultCenter]postNotificationName:@"LookBtnDidTapGigImageDisplay" object:self.index];
        
    }
    
    
    if ([_model.pay_status isEqualToString:@"0"]) {
        
        [[NSNotificationCenter defaultCenter]postNotificationName:@"MyCellPayBtnDidTap" object:self.model];

    }
    
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
